package model;

import java.awt.*;
import java.util.List;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;

public class Ghost {
    public int row, col;
    private Image image;

    public Ghost(int row, int col, String imagePath) {
        this.row = row;
        this.col = col;
        try {
            this.image = ImageIO.read(new File(imagePath));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Image getImage() {
        return image;
    }

    // 预留AI移动方法
    public void moveBFS(Map map, int targetRow, int targetCol) {
        int startId = row * Map.COLS + col;
        int targetId = targetRow * Map.COLS + targetCol;
        List<Integer> path = map.getGraph().bfs(startId, targetId);
        if (path != null && path.size() > 1) {
            int nextId = path.get(1);
            row = nextId / Map.COLS;
            col = nextId % Map.COLS;
        }
    }
    public void moveDFS(Map map, int targetRow, int targetCol) {
        // DFS逻辑后续补充
    }
} 